package Jsontest.json;

import javax.json.bind.annotation.*;
import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * @author Sai
 * Created by Sai on 2019-03-15.
 * @see JsonbProperty - 用于指定自定义字段名称
 * @see JsonbTransient - 当我们想要在反序列化/序列化期间忽略该字段时
 * @see JsonbDateFormat - 当我们想要定义日期的显示格式时
 * @see JsonbNumberFormat - 用于指定数值的显示格式
 * @see JsonbNillable - 用于启用空值的序列化
 */
public class StudentDTO {

    private int id;
    // 学号
    @JsonbProperty("学号")
    private String name;
    // 姓名s
    @JsonbProperty("姓名")
    private String username;
    // 班级
    @JsonbProperty("班级")
    private String myClass;
    // 性别
    @JsonbProperty("性别")
    private String sex;
    // 身份
    @JsonbProperty("身份")
    private String identity;
    // 年龄
    @JsonbTransient
    private int age;

    // 为了使用jsonb,必须有一个空的默认构造方法
    public StudentDTO() {

    }

    public StudentDTO(String name, String username, String identity,String myClass, String sex, int age) {
        this.name = name;
        this.username = username;
        this.identity = identity;
        this.age = age;
        this.myClass = myClass;
        this.sex = sex;
    }

    @JsonbNumberFormat(locale = "en_US", value = "#0.0")

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getIdentity() {
        return identity;
    }

    public void setIdentity(String identity) {
        this.identity = identity;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getMyClass() {
        return myClass;
    }

    public void setMyClass(String myClass) {
        this.myClass = myClass;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}
